227A - Where do I Turn - CodeForces Solution


geometry *1300

Please click on ads to support us..

Python Code:




















import math

a1, a2 = [int(x) for x in input().split()]
b1, b2 = [int(x) for x in input().split()]
c1, c2 = [int(x) for x in input().split()]

diff1 = (b1-a1, b2-a2)
diff2 = (c1-b1, c2-b2)

def get_theta_angle(d):
	if(d[0] == 0):
		if(d[1] > 0):
			return math.pi / 2
		else:
			return 3 * math.pi / 2
	elif(d[0] > 0):
		return math.atan(d[1]/d[0])
	else:
		return math.atan(d[1]/d[0]) + math.pi

def correct_large_diff(angle1, angle2):
	if(angle1 > angle2 + math.pi):
		angle2 = angle2 + 2 * math.pi
	elif(angle2 > angle1 + math.pi):
		angle1 = angle1 + 2 * math.pi
	return angle1, angle2

angle1 = get_theta_angle(diff1)
angle2 = get_theta_angle(diff2)

angle1, angle2 = correct_large_diff(angle1, angle2)

if(angle1 - angle2 == 0):
	print("TOWARDS")
if(angle1 - angle2 < 0):
	print("LEFT")
if(angle1 - angle2 > 0):
	print("RIGHT")












Comments

Submit
0 Comments
More Questions

1608B - Build the Permutation
1505A - Is it rated - 2
169A - Chores
765A - Neverending competitions
1303A - Erasing Zeroes
1005B - Delete from the Left
94A - Restoring Password
1529B - Sifid and Strange Subsequences
1455C - Ping-pong
1644C - Increase Subarray Sums
1433A - Boring Apartments
1428B - Belted Rooms
519B - A and B and Compilation Errors
1152B - Neko Performs Cat Furrier Transform
1411A - In-game Chat
119A - Epic Game
703A - Mishka and Game
1504C - Balance the Bits
988A - Diverse Team
1312B - Bogosort
1616B - Mirror in the String
1660C - Get an Even String
489B - BerSU Ball
977C - Less or Equal
1505C - Fibonacci Words
1660A - Vasya and Coins
1660E - Matrix and Shifts
1293B - JOE is on TV
1584A - Mathematical Addition
1660B - Vlad and Candies